<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin_contact extends CI_Controller {

	function index()
	{
		$data['error'] ='display: none;';
		$data['contact']  ='active';
		if($this->session->userdata('email') || $this->session->userdata('logged'))
		{	
				$data['title'] = 'Admin Contact';	
				$this->load->model('admin_model');
				$data['message'] = $this->admin_model->list_message();	
				$data['content'] = 'admin/admin_contact';
				$this->load->view('admin/template/template_DT',$data);
						
		}
		else 
		{
			$this->load->view('admin/signup',$data);
		}
	}

	function read_message()
	{
		if($this->session->userdata('email') || $this->session->userdata('logged'))
		{	
			if ($this->uri->segment(3)) 
			{		


					$this->load->model('admin_model');

					$data = array(
					'contact_statut' => 'normal',
					);
					$this->admin_model->update_message($this->uri->segment(3),$data);


					$data['rows'] = $this->admin_model->get_message($this->uri->segment(3));
					$data['id_contact_infos'] = $data['rows']->id_contact_infos;
					$data['contact_name'] = $data['rows']->contact_name;
					$data['contact_surname'] = $data['rows']->contact_surname;
					$data['contact_email'] = $data['rows']->contact_email;
					$data['contact_reciever'] = $data['rows']->contact_reciever;
					$data['contact_message'] = $data['rows']->contact_message;
					$data['contact_statut'] = $data['rows']->contact_statut;
					$data['contact_date'] = $data['rows']->contact_date;		
					$data['contact_time'] = $data['rows']->contact_time;

					
					$data['title'] = 'Admin Contact';	
					$data['contact']  ='active';
					$data['content'] = 'admin/admin_contact_details';
					$this->load->view('admin/template/template',$data);
					
			} 

			else
			{
				$data['title'] = 'Admin Contact';	
				$this->load->model('admin_model');
				$data['message'] = $this->admin_model->list_message();	
				$data['content'] = 'admin/admin_contact';
				$this->load->view('admin/template/template_DT',$data);
			}
		}		
		else
		{
			$this->load->view('admin/signup',$data);
		}		
	}
	
	function delete_message()
	{
		if($this->session->userdata('email') || $this->session->userdata('logged'))
		{
			if($this->uri->segment(3))
			{
			
			$data['success'] = 'display: block;';	
			$this->load->model('crud_model');
			$this->crud_model->delete_message($this->uri->segment(3));

			$data['title'] = 'Admin Contact';	
			$this->load->model('admin_model');
			$data['message'] = $this->admin_model->list_message();	
			$data['content'] = 'admin/admin_contact';

			$this->load->view('admin/template/template_DT',$data);	
			}
			else 
			{
			
			$data['error'] = 'display: block;';
			$data['title'] = 'Admin Contact';	
			$this->load->model('admin_model');
			$data['message'] = $this->admin_model->list_message();	
			$data['content'] = 'admin/admin_contact';

			$this->load->view('admin/template/template_DT',$data);	
			
			}
		}
		else {
			$this->load->view('admin/signup');
		}
	}
	
	
	
	
}		
?>